home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Scout-src.lha / netinclude / libraries / ifconfig.h next >
C/C++ Source or Header  |  2002-09-16  |  7KB  |  182 lines

  1. #ifndef LIBRARIES_IFCONFIG_H
  2. #define LIBRARIES_IFCONFIG_H \
  3.        "$Id: ifconfig.h,v 1.1.1.1 2001/11/26 22:21:16 tboeckel Exp $"
  4. /*
  5.  *    Definitions of AmiTCP/IP ifconfig.library
  6.  *
  7.  *      Copyright © 1995 AmiTCP/IP Group,
  8.  *                       Network Solutions Development, Inc.
  9.  *                       All rights reserved.
  10.  */
  11. #ifndef EXEC_TYPES_H
  12. #include <exec/types.h>
  13. #endif
  14.  
  15. #ifndef DOS_RDARGS_H
  16. #include <dos/rdargs.h>
  17. #endif
  18.  
  19. #ifndef UTILITY_TAGITEM_H
  20. #include <utility/tagitem.h>
  21. #endif
  22.  
  23. /*
  24.  * Name and version of the library described by this header
  25.  */
  26. #define IFCONFIGNAME "AmiTCP:libs/ifconfig.library"
  27. #define IFCONFIGVERSION 0
  28.  
  29. /*
  30.  * Interface type definitions. Note that these are BIT positions, and only
  31.  * one of the bits is set in ifc_type field of if_config.
  32.  */
  33. #define IFCT_SANA 1
  34. #define IFCT_SLIP 2
  35. #define IFCT_PPP  4
  36.  
  37. /*
  38.  * Information on each configuration item. This is used internally by the
  39.  * library, and returned by the IfConfigGetTagInfo().
  40.  * Note that this structure is READ ONLY when returned by IfConfigGetTagInfo(),
  41.  * and it may grow in future (in such vase the library version number will
  42.  * grow, too).
  43.  */
  44. struct ifc_confitem {
  45.   const char * ci_Names;
  46.   const char * ci_CanonicalName;/* canonical form of the name */
  47.   Tag          ci_TagValue;    /* data type is encoded into the tag value */
  48.   UWORD        ci_TypesAllowed;    /* mask of allowed interface types */
  49.   UWORD        ci_Flags;    /* misc flags, defined below */
  50. };
  51. /*
  52.  * ci_Flags definitions
  53.  */
  54. #define CIF_REQUIRED        (1<<0)
  55. #define CIF_NOT                 (1<<1) /* switch defaults to 1, turn to 0 */
  56.  
  57. /*
  58.  * Tag item values for the interface configuration information
  59.  *
  60.  * Note that the name and type are parsed separately, and they do not
  61.  * have corresponding tag values.
  62.  */
  63.  
  64. /*
  65.  * data type number bits 16 - 23
  66.  */
  67. #define IFTB_TYPE 16        /* starts from 16th bit */
  68. /*
  69.  * argument passing convention (bit 8 WITHIN type) 
  70.  */
  71. #define IFTF_REF 0x80        /* not set == by value */
  72. #define IFTM_REF(tag) (((tag) >> IFTB_TYPE) & IFTF_REF)
  73. #define IFTS_TYPE 0x7F        /* mask after shift by IFTB_TYPE */
  74. #define IFTM_TYPE(tag) (((tag) >> IFTB_TYPE) & IFTS_TYPE)
  75. #define IFTM_REFTYPE(tag) (((tag) >> IFTB_TYPE) & (IFTF_REF | IFTS_TYPE))
  76. /*
  77.  * Code (bits 0 - 15)
  78.  */
  79. #define IFTS_CODE 0xFFFF
  80. #define IFTM_CODE(tag) ((tag) & SBTS_CODE)
  81.  
  82. /*
  83.  * Defined data types (tag value type on comments)
  84.  */
  85.  
  86. #define CI_TYPE_TYPE                    0    /* XXX - internal only */
  87. #define CI_TYPE_STRING        (IFTF_REF | 1)    /* null terminated string */
  88. #define CI_TYPE_LONG                    2    /* long integer */
  89. #define CI_TYPE_SWITCH                    3    /* boolean */
  90. #define CI_TYPE_HEXSTRING    (IFTF_REF | 4)    /* byte length + data */
  91. #define CI_TYPE_DOTNOT        (IFTF_REF | 5)    /* struct sockaddr_in */
  92. #define CI_LAST_TYPE                5    /* last type value */
  93. /*
  94.  * Macros to define the actual tag codes - one for each type
  95.  */
  96. #define IFTM_STRING(code) (TAG_USER | (CI_TYPE_STRING << IFTB_TYPE) | (code))
  97. #define IFTM_LONG(code) (TAG_USER | (CI_TYPE_LONG << IFTB_TYPE) | (code))
  98. #define IFTM_SWITCH(code) (TAG_USER | (CI_TYPE_SWITCH << IFTB_TYPE) | (code))
  99. #define IFTM_HEXSTRING(code) (TAG_USER | (CI_TYPE_HEXSTRING << IFTB_TYPE) | (code))
  100. #define IFTM_DOTNOT(code) (TAG_USER | (CI_TYPE_DOTNOT << IFTB_TYPE) | (code))
  101.  
  102. /*
  103.  * The actual tag codes
  104.  */
  105. #define IF_Device    IFTM_STRING(     1) /* Exec device name */
  106. #define IF_Unit        IFTM_LONG(       2) /* Exec device unit */
  107. #define IF_Address    IFTM_HEXSTRING(  3) /* Sana-II HW-address */
  108. #define IF_IPType    IFTM_LONG(       4) /* IP protocol type */
  109. #define IF_MTU        IFTM_LONG(       5) /* (Transmit) MTU */
  110. #define IF_SerBaud    IFTM_LONG(       6) /* Serial baud rate */
  111. #define IF_SerBufLen    IFTM_LONG(       7) /* Serial read buffer length */
  112. #define IF_CD        IFTM_SWITCH(     8) /* Serial flag: Carrier Detect */
  113. #define IF_7Wire    IFTM_SWITCH(     9) /* Serial flag: CTS/RTS handshake */
  114. #define IF_EOFMode    IFTM_SWITCH(    10) /* Serial flag: EOF-mode */
  115. #define IF_Shared    IFTM_SWITCH(    11) /* Serial flag: Shared mode */
  116. #define IF_UseODU    IFTM_SWITCH(    12) /* Serial flag: Use OwnDevUnit */
  117. #define IF_ARPType    IFTM_LONG(      13) /* ARP protocol type */
  118. #define IF_IPReq    IFTM_LONG(      14) /* # of IP read requests */
  119. #define IF_ARPReq    IFTM_LONG(      15) /* # of ARP read requests */
  120. #define IF_WriteReq    IFTM_LONG(      16) /* # of write requests */
  121. #define IF_Tracking    IFTM_SWITCH(    17) /* Sana2: Type tracking */
  122. #define IF_QuickIO    IFTM_SWITCH(    18) /* Sana2: QuickIO */
  123. #define IF_Filter    IFTM_SWITCH(    19) /* Sana2: Use Filter Hook */
  124. #define IF_NoARP    IFTM_SWITCH(    20) /* Flag: No ARP */
  125. #define IF_ARPHdr    IFTM_LONG(      21) /* ?? */
  126. #define IF_P2P        IFTM_SWITCH(    22) /* Flag: Point-to-point interface */
  127. #define IF_Simplex    IFTM_SWITCH(    23) /* Flag: iface receives own bcasts */
  128. #define IF_Loopback    IFTM_SWITCH(    24) /* Flag: iface is of loopback type */
  129. #define IF_Compress    IFTM_SWITCH(    25) /* Slip flag: Compress headers */
  130. #define IF_NoICMP    IFTM_SWITCH(    26) /* Slip flag: No ICMP traffic */
  131. #define IF_AutoComp    IFTM_SWITCH(    27) /* Slip flag: Compress detection */
  132. #define IF_OnlineScript IFTM_STRING(    28) /* Serial: Dialing script */
  133. #define IF_OfflineScript IFTM_STRING(   29) /* Serial: Hangup script */
  134. #define IF_ReconnectScript IFTM_STRING( 30) /* Serial: Reconnect script */
  135. #define IF_IP        IFTM_DOTNOT(    31) /* IP address of the interface */
  136. #define IF_Netmask    IFTM_DOTNOT(    32) /* Netmask of the interface */
  137. #define IF_DestIP    IFTM_DOTNOT(    33) /* Dest. IP addr of the iface */
  138. #define IF_Gateway    IFTM_DOTNOT(    34) /* Def. gateway for this interface */
  139. #define IF_UseBootP    IFTM_SWITCH(    35) /* Use BootP to configure iface */
  140. #define IF_AutoConfig    IFTM_SWITCH(    36) /* Configure this iface on startup */
  141. #define IF_ConfigFileName IFTM_STRING(  37) /* Sana2 configuration file name */
  142. #define IF_ConfigFileContents IFTM_STRING( 38) /* Sana2 configuration contents */
  143. #define IF_DoOnline    IFTM_SWITCH(    39) /* AmiTCP: put device online at start */
  144. #define IF_DoOffline    IFTM_SWITCH(    40) /* AmiTCP: put device offline at end */
  145. #define IF_MAXTAGS                       40  /* # of defined tag codes */
  146.  
  147. /*
  148.  * The interface configuration structure returned by the ifconfig_find(),
  149.  * if entry for the searched interface was found.
  150.  */
  151. struct ifconfig {
  152.   struct Node        ifc_node; /* read only */
  153.   char            ifc_name[16]; /* IFNAMSIZ */
  154.   LONG            ifc_type; /* IFCT_SANA, IFCT_SLIP or IFCT_PPP */
  155.   struct TagItem *    ifc_taglist;
  156.   UBYTE            ifc_databuf[0]; /* private */
  157. };
  158.  
  159. /*
  160.  * The ifconfig.library functions return dos error codes + some
  161.  * extended error codes.
  162.  * IfConfigStrError() should be used to convert these codes to 
  163.  * english language text strings.
  164.  * 
  165.  * The normal error code is in the lower word of the returned error code
  166.  * Upper half contains private information about the error.
  167.  * When comparing the error code to the defined values, the upper half must 
  168.  * be masked away with the following macro
  169.  */
  170.  
  171. #define IFCONFIG_ERROR(x) ((unsigned short)x)
  172.  
  173. /* extended IoErr codes */
  174. #define ERROR_IFCONFIG_BASE            1024
  175. #define ERROR_TYPE_MUST_BE_FIRST        1024
  176. #define ERROR_TYPE_NOT_KNOWN            1025
  177. #define ERROR_OPTION_NOT_ALLOWED_FOR_TYPE    1026
  178. #define ERROR_OPTION_NOT_KNOWN            1027
  179. #define ERROR_IFCONFIG_MAX            1027
  180.  
  181. #endif /* LIBRARIES_IFCONFIG_H */
  182.